Cisco Router OSPF Design and Implementation Guide William Parkhurst, PhD, CCIE $54.95 0-07-048626-3 |
![]() ![]() |
Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
Reserve your copy at a Beta Bookstore near you! |
Contact Bet@books © 1998 The McGraw-Hill Companies, Inc. All rights reserved. Any use of this Beta Book is subject to the rules stated in the Terms of Use. |
In order to become an expert OSPF network designer (remember the E in CCIE) you must first become an expert at working with the Internet Protocol (IP) addressing scheme. OSPF is an IP only routing protocol and cannot be used to route any other protocol. Many of the powerful features of OSPF are difficult, if not impossible, to implement without a mastery of IP addressing. This chapter contains everything you wanted to know about IP addressing, but were afraid to ask.
IP Address Format
An IP address is a 32-bit number that can be represented in many formats. Routers and computers are designed to operate efficiently on binary numbers so a binary representation is a natural way for them to store and manipulate IP addresses. A typical 32-bit IP address to a router would look something like
10111100000110100001111000111100.
This may be a fine representation for routers, but for humans it is not the most appealing method. So let’s take a look at the binary representation and see if we can find a way to represent these numbers using a method that may be a bit more palatable. One way is to simply represent the IP address as a decimal number. The binary number used in the
example above has a decimal value of
2,618,957,372.
This may be easier to read but the size of the number makes it cumbersome to work with. Another representation scheme is to break up the binary number into pieces and represent each piece as a decimal number. A natural size for binary pieces is 8 bits, which is the familiar byte or not as familiar octet (Octet is the telecommunication term but the two words can be used interchangeably). So let’s take our binary number, write it using groups of 8 bits (4 octets) and then represent each group as a decimal number.
10111100 00011010 00011110 00111100
156 26 30 60.
We don’t need all that space between the numbers so let’s use a period, or dot, as a separator. Now our IP address has the form
156.26.30.60
which is referred to as the dotted decimal notation. How many IP addresses are there? The range of IP addresses in all our representation schemes is shown in table 3.1
Table 3.1. Range of IP Addresses
Low |
High |
|
Binary |
00000000000000000000000000000000 |
11111111111111111111111111111111 |
Decimal |
0 |
4,294,967,295 |
Dotted Decimal |
0.0.0.0 |
255.255.255.255 |
Theoretically there are 4,294,967,296 possible IP addresses although we will discover in this chapter that the actual usable number of IP addresses is much smaller.
Classful IP Addressing
For a protocol to be routable its address structure must be hierarchical meaning that the address must contain at least two parts. For IP addresses these parts are the network portion and the host portion. A host is an end station such as a computer workstation, router interface or printer while a network consists of one or more hosts. Figure 3.1 is a simple network consisting of two networks connected by a two port router. The address of each host on this network, including the router interfaces, is given by its network and host numbers.
When the IP address scheme was designed the decision was made to create five classes of IP addresses named simply class A, B, C, D, and E. The logic behind the first three network classes was that the IP addressing scheme would be used for a few networks with a large number of hosts (Class A), a moderate number of networks with a moderate number of hosts (Class B), and a large number of networks with a small number of hosts (Class C). Class D addresses are used for multicasting and Class E addresses are reserved for experimental use. Having three classes of IP addresses to handle different size networks requires that the network part and the host part for each address class have unequal sizes. The breakdown of the allocation of bits for the network and host portion for the first three IP address classes is shown in figure 3.2
0 7 8 31
0 |
Network |
Host |
a. Class A
0 1 2 15 16 31
1 |
0 |
Network |
Host |
b. Class B
0 1 2 3 23 24 31
1 |
1 |
0 |
Network |
Host |
c. Class C
Figure 3.2. Classful IP Address Structure
Class A addresses use 8 bits to identify the network and 24 bits to identify the host with the most significant bit of the first octet set to zero. Class B addresses use 16 bits to identify the network and 16 bits to identify the host with the first two bits of the first octet
set to 0 1. Class C addresses use 24 bits to identify the network and 8 bits to identify the host with the first 3 bits of the first octet set to 1 1 0. If we examine the first octet of each class we can see that the range of values for the three classes is
00000001 (1) – 01111110 (126) for Class A
10000000 (128) – 10111111 (191) for Class B and
11000000 (192) – 11011111 (223) for Class C.
Looking at the first octet of the IP address can easily identify the network class. For example, the address used previously, 156.26.30.60, is a class B address since the first octet is between 128 and 191. Another (and more tedious) way to identify the class is to represent the first octet of the address in binary and see what the first couple of bits are set to. For example, 156 = 10011100 in binary. The first 2 bits are 1 0 so according to figure 3.1 this is a class B address.
How many class A, B, and C networks are there? Class A networks use 7 bits for the network ID so there are 126 class A networks possible. Class B addresses use 6 bits from the first octet and all 8 bits of the second octet so there are 64 * 256 (64 from the first octet and 256 from the second octet) = 16384 networks. Class C addresses use 5 bits form the first octet, 8 bits from the second octet and 8 bits from the third octet so there are 32 * 256 * 256 = 2,097,152 possible class C networks. How many hosts can each network have? Class A networks have 24 bits to identify a host which equals 1,677,216 possible hosts per network (WOW!). Class B networks have 16 bits to identify a host which equals 65536 hosts and Class C networks have 8 bits to identify a host which equals 256 possible hosts. Table 3.2 lists the capabilities for Class A, B, and C addresses.
Table 3.2. IP Classful Address Capabilities
Class |
Networks |
Hosts |
A |
126 |
16777214 |
B |
16384 |
65534 |
C |
2,097,152 |
254 |
You may have noticed that the number of hosts listed in table 3.1 is always two less than the number calculated. The reason for this discrepancy is that there are two special addresses that can’t be assigned to a host. A host address of all 1s is the broadcast address for a particular network and a host address of all 0s is used by a host to temporarily identify itself ("this host") until it has been assigned an IP address. There are only 126 class A networks because network 0 cannot be used and network 127 is reserved for the loopback address which is used for testing inter-process communication. When a host sends a packet to 127.0.0.1 the data is not sent on the network but is returned immediately to the sending host.
Classful IP addresses are extremely inefficient as the following design problem demonstrates. Assume we are designing a network for a campus that has approximately 1500 nodes or end-stations. Also assume that the predicted future growth of the network over the next five years will be no more than 5000 nodes. At first glance it would seem that a class B network would suffice for the current network requirements and also leave plenty of room for future growth. Recalling from chapter two the problems associated
with a large ethernet network we can see those 1500+ nodes (5000+ in the future) would be a very large collision domain. If we want to limit the number of nodes on an ethernet segment to no more than 100, then we need 50 networks to accomplish our design. Regardless of which class of IP network addresses we decide to use (assuming we could choose any addresses we want) there is going to be an enormous waste of IP addresses as shown in table 3.3.
Table 3.3. IP Address Design Inefficiencies
Network Class |
Addresses Required |
Addresses Available |
Addresses Wasted |
A |
100 |
16,777,214 |
16,777,214 |
B |
100 |
65534 |
65434 |
C |
100 |
254 |
154 |
Now multiply each entry in Table 3.3 by the 50 networks that are required and you can easily see that regardless of which address class we choose an enormous number of IP addresses will be wasted. Also, if we are to have connectivity to the Internet, then are network will have to advertise 50 networks to the Internet routers. Multiply that by the number of campuses in the world and you have a situation where the size of the Internet routing tables becomes unmanageable. How do we overcome these problems? In a word, subnetting.
IP Subnets
The solution to our design problem is to divide whatever class of IP address we are assigned into a number of smaller networks with fewer hosts per network. This is accomplished by "borrowing" bits from the host portion of our IP address and using them
in the network portion. How do we, and more importantly, how does a router know how many bits to use for the network and how many to use for the host? The answer is by using a subnet mask. A subnet mask is a 32-bit binary number, which identifies which bits in the address are used for the host and which bits are used for the network. A 1 in the mask identifies the corresponding bit in the IP address as a network bit and a 0 in the mask identifies the corresponding bit in the IP address as a host bit. This operation is accomplished by a router by performing a bitwise AND operation with the IP address and the subnet mask.
0 AND 0 = 0 0 AND 1 = 0
1 AND 0 = 0 1 AND 1 = 1
As an example consider the IP address/subnet mask pair
156.26.30.60/255.255.240.0
which have the binary representations
10111100 00011010 00011110 00111100
11111111 11111111 111100000 00000000
Performing the AND operation yields
10111100 00011010 00010000 00000000
Converting the result to dotted decimal notation yields the network portion of the IP address
156.26.16.0
One subnet mask restriction is that the 1 bits in the mask must be contiguous. Since the 1 bits are contiguous an alternative representation for the mask is to just indicate how many 1 bits are in the mask. For example the IP address/subnet mask pair in the previous example can be written as 156.26.30.60/20.
The subnet masks for non-subnetted networks are shown in figure 3.2.
Class A
11111111.00000000.00000000.00000000
255.0.0.0
Class B
11111111.11111111.00000000.00000000
255.255.0.0
Class C
11111111.11111111.11111111.00000000
255.255.255.0
Figure 3.3. Standard IP Subnet Masks
Subnet masks will never have fewer ones than are listed in figure 3.3. For example a class C address cannot have a subnet mask of 255.255.0.0. RFC 950 first defined the subnetting of IP addresses. RFC 950 did not allow the use of the all 0s and all 1s subnet so we will initially look at subnetting examples that obey these restrictions. In later examples we will see how we can remove these restriction with the use of an appropriate routing protocol such as OSPF. The number of subnet bits cannot be 1 (Tables 3.4 and
3.5) because of the restriction in RFC 950. A 1-bit subnet mask would have a value of either 0 (all 0s) or 1 (all 1s) and this is not allowed. A 15-bit subnet mask for class B and
Table 3.4. Class B Subnet Masks
Number of Subnet bits |
Subnet Mask |
Number of Subnetworks |
Number of Hosts/Subnet |
Total Number of Hosts |
1 |
- |
- |
- |
|
2 |
255.255.192.0 |
2 |
16382 |
32764 |
3 |
255.255.224.0 |
6 |
8190 |
49140 |
4 |
255.255.240.0 |
14 |
4094 |
57316 |
5 |
255.255.248.0 |
30 |
2046 |
61380 |
6 |
255.255.252.0 |
62 |
1022 |
63364 |
7 |
255.255.254.0 |
126 |
510 |
64260 |
8 |
255.255.255.0 |
254 |
254 |
64516 |
9 |
255.255.255.128 |
510 |
126 |
64260 |
10 |
255.255.255.192 |
1022 |
62 |
63364 |
11 |
255.255.255.224 |
2046 |
30 |
61380 |
12 |
255.255.255.240 |
4094 |
14 |
57316 |
13 |
255.255.255.248 |
8190 |
6 |
49140 |
14 |
255.255.255.252 |
16382 |
2 |
32764 |
15 |
- |
- |
- |
|
16 |
- |
- |
- |
Table 3.5. Class C Subnet Masks
Number of Subnet bits |
Subnet Mask |
Number of Subnetworks |
Number of Hosts/Subnet |
Total Number of Hosts |
1 |
- |
- |
- |
|
2 |
255.255.255.192 |
2 |
62 |
124 |
3 |
255.255.255.224 |
6 |
30 |
180 |
4 |
255.255.255.240 |
14 |
14 |
196 |
5 |
255.255.255.248 |
30 |
6 |
170 |
6 |
255.255.255.252 |
62 |
2 |
124 |
7 |
- |
- |
- |
- |
8 |
- |
- |
- |
- |
a 7-bit subnet mask for class C is also illegal because it would leave only 1-bit for the host which we have seen cannot be all 0s or all 1s. A 16-bit subnet mask for class B or an 8-bit subnet mask for class C makes no sense since this would leave 0 host bits.
Exercise 3.1
Create a table similar to tables 3.4 and 3.5 for Class A addresses.
Subnet Examples
In the following examples determine if the Address/Subnet pair is legal. If it is legal determine the network number and the range of host addresses for that network. Also determine for the mask given the number of available networks and available hosts per network.
For a class C address we only need to look at the last octet of the address and the mask.
130 = 1000 0010
192 = 1100 0000
Legal pair since the neither the subnet nor the host is all 0s or all 1s.
Network = 193.144.233.128 because the mask selects the upper 2 bits of the address (130) and the rest of the bits are set to 0 to identify the network.
Range of hosts = 193.144.233.129 – 193.144.233.191
The host portion (last 6 bits) can have values ranging from 000001 to 111110 (remember they can’t be all 0s or all 1s). Add in the subnet portion which is the upper 2 bits of the address, in his case 1 0 and you have 10 000001 to 10 111110 for the host addresses.
From table 3.5 the number of available networks is 2 and the number of hosts is 62.
2. IP address = 156.26.30.60 Subnet Mask = 255.255.255.0
This is relatively easy since the entire 3rd octet is used for the subnet and the entire 4th octet is used for the host. This is a legal pair since neither the subnet nor the host is all 0s or all 1s.
Network = 156.26.30.0
Range of hosts = 156.26.30.1 – 156.26.30.254
From table 3.4 the number of networks is 254 and the number of hosts is 254.
3. IP address = 199.200.201.50 Mask = 255.255.255.128
This is illegal since the subnet mask only borrows 1 bit from the host and that bit has to be either 0 or 1.
4. IP address = 191.200.201.50 Mask = 255.255.255.128
This is a legal pair because the address is class B and we are borrowing 9 bits from the host portion.
Network = 191.200.201.0
Range of hosts = 191.200.201.1 – 191.200.201.126
From table 3.3 the number of networks is 510 and the number of hosts is 126.
Exercise 3.2
Complete table 3.6.
Table 3.6. Exercise 3.2.
IP Address |
Subnet Mask |
Valid Pair? |
Network Number |
Range of Hosts |
144.223.136.231 |
255.255.255.192 |
|||
184.16.34.10 |
255.255.255.224 |
|||
12.14.1.2 |
255.255.0.0 |
|||
193.15.16.1 |
255.255.255.252 |
Subnetting can be viewed as creating a three part hierarchical address. The network portion of the address can be found by applying the standard subnet mask (figure 3.3) to the IP address. The subnet is determined from the bits "borrowed" from the host portion
and the host number is simply those bits that are leftover. For an example we will examine the class B address/mask pair
144.223.0.0/255.255.255.0
and determine the network number, the subnetwork numbers and the range of host numbers. The network number is found by applying the standard class B 16-bit subnet
mask which yields the network
144.223.0.0
The subnet is the entire 3rd octet so the 254 subnets are
144.223.1.0
144.223.2.0
.
.
.
144.223.254.0
and the range of hosts for each subnet is 1 to 254. Now lets try a bit more complicated example. Consider the address/mask pair
144.223.0.0/255.255.255.224
The network number is still 144.223.0.0. The subnet mask borrows 11 bits from the host portion of the address. The first 8 bits borrowed include the entire 3rd octet which has a value of 0 to 255. The 3 bits borrowed from the 3rd octet have the values
000 00000 = 0
001 00000 = 32
010 00000 = 64
011 00000 = 96
100 00000 = 128
101 00000 = 160
110 00000 = 192
111 00000 = 224
Why are the values 0 (all 0s) and 255 (all 1s) for the third octet and 0 (all 0s) and 224 (all 1s) from the 4th octet included? The 3rd octet can be 0 if the 3 bits in the 4th octet are not zero. The 3rd octet can be all 1s if the 3 bits in the 4th octet are not all 1s. The 3 bits in the 4th octet can be all 0s if the 3rd octet is not all 0s and the 3 bits from the 4th octet can be all 1s if the 3rd octet is not all 1s. Rewording slightly the 11 subnet bits can not be all 0s or all 1s. Therefore the range of subnet numbers is
144.223.0.32
144.223.0.64
.
.
.
144.223.0.224
144.223.1.0
144.223.1.32
.
.
.
144.223.255.0
.
.
.
144.223.255.192
Determining the range of host addresses for each subnet requires more effort. The bit pattern for the 4th octet of network 144.223.0.32 is
001 hhhhh
where hhhhh represents the host number which cannot be all 0s or all 1s so the first legal host number is 00001 which makes the 4th octet
00100001 = 33
so the first host address is
144.223.0.33
and the last legal host bit pattern for the 4th octet is
00111110 = 62
which gives the range of hosts addresses for the first subnet
144.223.0.33 – 144.223.0.62.
The broadcast address for each subnet is found by setting all the bits in the host portion to 1. The broadcast address for subnet 144.223.0.32 is determined by setting the last 5 bits of the 4th octet to 1 yielding
00111111 = 63.
Putting it all together gives us the broadcast address
144.223.0.63.
Exercise 3.3
Determine all the subnet numbers for the address/mask pair 193.128.55.0/255.255.255.240. Also determine the range of host addresses and the broadcast address for the 4th subnet.
IP Address Design Example 1
Assume your company has been assigned the class C address 198.28.61.0 and you have determined that you require 4 networks with a maximum of 25 hosts per network. From table 3.5 you will need 3 subnet bits resulting in a subnet mask of 255.255.255.224. The subnet numbers for this design are any four of the following as shown in figure 3.4.
198.28.61.32
198.28.61.64
198.28.61.96
198.28.61.128
198.28.61.160
198.28.61.192.
Although subnets solve some of the problems associated with the inefficient use of the IP address space there are situations when simple subnetting does not suffice. Consider the network in figure 3.5. Two routers are connected by a serial link. This serial link is a point-to-point connection so there will only be two hosts on the link, the two router interfaces. Each network must be on a separate subnet so no matter which subnet mask we choose we will be wasting IP addresses. If we are using a class B address with a 24-bit subnet mask then the subnet assigned to the serial link will only use 2 out of a possible 254 host addresses.
If we could use different subnet masks for different subnetworks then the limitations of figure 3.5 could be solved. A subnet mask of 255.255.255.252 (or /30) can accommodate only two hosts which is perfect for a point-to-point serial link. Unfortunately this mask, if used throughout the network, would limit all subnets to two hosts. The ideal solution is to be able to vary the length of the subnet mask and adjust it according to the needs of each individual network.
Variable Length Subnet Masks (VLSM)
RFC 1009, 1987, specifies the procedures for using multiple subnet masks. This technique is referred to as variable length subnet masks (VLSM). The term VLSM can be confusing because the subnet mask for a specific network does not vary but is fixed. VLSM means that the subnet masks for different subnets can have unequal lengths. VLSM would allow assigning a subnet mask of 255.255.255.252 to a serial link and 255.255.255.0 to an ethernet network but once the masks are assigned they do not change, at least by themselves. The VLSM technique is very useful for allocating IP addresses more efficiently (less waste) and for reducing the size of routing tables (we’ll see how later in the book). But VLSM can also cause a number of massive network headaches if not used properly. As an introductory example, lets apply VLSM to the network in figure 3.5. Assume we have been assigned the class B network 156.26.0.0. The ethernet networks are assigned addresses using a /24 subnet mask and we will use the first 2 networks with this mask, 156.26.1.0 and 156.26.2.0. The third network, 156.26.3.0 will be sub-subnetted using a /30 subnet mask which will give us a possible 62
sub-subnets that we can use for serial connections. Notice that we are subnetting an already subnetted network, 156.26.3.0. Figure 3.6 illustrates this technique.
Figure 3.6 visually represents the technique that should be used when using VLSM. Start with the standard subnet mask (/8, /16, or /24 for class A, B, or C). Determine the network with the required maximum number of hosts, in this case 254. Subnet using a mask that will give you networks that can handle the largest number of hosts that you need. For smaller networks, sub-subnet the large networks and keep going until you have satisfied your requirements.
VLSM Example 2
The best way to master a technique is practice, practice, practice, so here we go.
Given the IP network 202.128.236.0 design a network with the following requirements:
Starting with the greatest number of hosts per network we can use a /27 subnet mask to satisfy the first requirement. From table 3.5 this will give us 6 networks of 30 hosts each with two networks left over to sub-subnet. To satisfy the next requirement, we can sub-subnet the two leftover /27 networks using a /28 subnet mask to give us 4 networks with 14 hosts each. Finally take one of the four sub-subnetted networks and sub-sub-subnet using a /30 subnet mask
How did I arrive at the diagram in figure 3.7? Lets take a very close look at where these network numbers came from and then I’ll give you a VLSM design problem to ensure that you have mastered the technique.
Step 1. Determine the mask for the networks containing the greatest number of hosts.
The first requirement was for 4 networks with a maximum of 26 hosts. Using table 3.4 we need 3 subnet bits or a /27 subnet mask. The 4th octet of our IP network would be segmented as
S S S H H H H H
Where S S S indicates the subnet bits and H H H H H indicates the host bits. The subnets when then be
0 0 1 0 0 0 0 0 = 32
0 1 0 0 0 0 0 0 = 64
0 1 1 0 0 0 0 0 = 96
1 0 0 0 0 0 0 0 = 128
1 0 1 0 0 0 0 0 = 160
1 1 0 0 0 0 0 0 = 192
and we are using subnets 96 through 192 for the networks containing 26 hosts since these subnets can handle a maximum of 30 hosts.
Step 2. Sub-subnet the subnetted networks as needed.
The second requirement calls for three networks with a maximum of 10 hosts each. Again we consult table 3.4 and see that we need 4 subnet bits or a /28 subnet mask. We will sub-subnet network 202.128.236.32 and 202.128.236.64. The first three subnet bits are fixed with the values 001 (subnet 32) and 010 (subnet 64) so now we have
0 0 1 S H H H H
0 1 0 S H H H H.
For network 32 S can be 0 or 1 giving us
0 0 1 0 H H H H and
0 0 1 1 H H H H.
Setting the host bits to 0 the sub-subnets are
0 0 1 0 0 0 0 0 = 32 and
0 0 1 1 0 0 0 0 = 48.
Applying the same procedure to subnet 64 we get
0 1 0 0 0 0 0 0 = 64 and
0 1 0 1 0 0 0 0 = 80.
Step 3. To satisfy the last requirement of 4 point-to-point serial links we will sub-sub-subnet sub-subnet 32 which now is equal to
0 0 1 0 S S H H.
S S can be either 0 0, 0 1, 1 0 , or 1 1 yielding
0 0 1 0 0 0 0 0 = 32
0 0 1 0 0 1 0 0 = 36
0 0 1 0 1 0 0 0 = 40
0 0 1 0 1 1 0 0 = 44.
As a finally task for this exercise determine the range of hosts and the broadcast addresses for networks 202.128.236.192, 202.128.236.80, and 202.128.236.40.
The 4th octet of network 202.128.236.192 is
1 1 H H H H H H and the host bits can range from 0 0 0 0 0 1 to 1 1 1 1 1 0 which gives us a range of
1 1 0 0 0 0 0 1 (193) to 1 1 1 1 1 1 1 0 (254). The broadcast address is determined by setting the host bits to 1 which is
1 1 1 1 1 1 1 1 = 255 so the broadcast address is 202.128.236.255.
For network 202.128.136.80 the 4th octet contains
0 1 0 1 H H H H so the range of host addresses is 0 1 0 1 0 0 0 1 (81) through
0 1 0 1 1 1 1 0 (94) and the broadcast address is 0 1 0 1 1 1 1 1 (95).
For network 202.128.136.40 the 4th octet contains
0 0 1 0 1 0 H H. Since H H cannot be 0 0 or 1 1 the host addresses for this network are
202.128.136.41 and 202.128.136.42 with a broadcast address of 202.128.136.243.
The realization of this network design is shown in figure 3.8.
Exercise 3.4.
Design a network using the class C address 200.100.50.0 that satisfies the following requirements:
Determine the address host ranges and the broadcast address for each subnet.
![]() ![]() Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
Reserve your copy at a Beta Bookstore near you! |
Contact Bet@books © 1998 The McGraw-Hill Companies, Inc. All rights reserved. Any use of this Beta Book is subject to the rules stated in the Terms of Use. |